package com.qinhailin.portal.dbm.service;

import java.util.List;

import com.jfinal.plugin.activerecord.Record;
import com.qinhailin.common.vo.Grid;
import com.qinhailin.portal.dbm.model.DTContact;
import com.qinhailin.portal.dbm.model.DTCustomerContact;

/** 2019-11-23 21:28:45 批量生成 harrydeep@wardyan.top **/
public class DTContactServiceImpl extends MasterServiceImpl<DTContact> {

	public DTContactServiceImpl() {super(DTContact.dao);}
	
	public Grid page(int pageNumber, int pageSize, Record record) {
		Record rd = new Record();
		rd.set("m.rCust_ID=", record.getStr("rCust_ID"));
		rd.set("m.xName LIKE", record.getStr("xName"));
		rd.set("n.xName LIKE", record.getStr("xCustName"));
		String sql="SELECT	m.*, c.xName AS xCustName FROM " + dao.tableName() + " AS m LEFT JOIN dbo.ct_customer AS c ON c.sID = m.rCust_ID WHERE 1 = 1";
		return queryForList(sql,pageNumber, pageSize, rd, null);
	}
	
	public List<DTContact> list(Integer rCustID){
		return this.List(this.sql + " AS m (NOLOCK) INNER JOIN " + DTCustomerContact.dao.tableName() + " AS n (NOLOCK) ON m.sID = n.rCont_ID WHERE n.mID = ?", rCustID);
	}
	
}
